<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>订单列表</title>
    {include file="public/header"/}
</head>
<body>

    <table class="table table-hover text-center" style="background-color: pink">
        <tr>
            <th width="100" style="text-align:left; padding-left:20px;">ID</th>
            <th width="15%">商品名称</th>
            <th>图片</th>
            <th width="310">操作</th>
        </tr>
        {volist name="db" id="v" empty="$empty"}
        <tr>
            <td style="text-align:left; padding-left:20px;"><input type="checkbox" class="goods_id" name="id[]" value="<{$v['goods_id']}>" /><{$v['goods_id']}></td>
            <td><{$v['goods_name']}></td>
            <td width="10%"><img src="/storage/<{$v['default_image']==''?'/__STATIC__/data/default.png':$v['default_image']}>" alt=""
                                 width="70" height="50"/></td>
            <td><div class="button-group"> <a class="button border-main" href="<{:url('recycle',['id'=>$v['goods_id']])}>"><span class="icon-edit"></span> 回收</a> <a class="button border-red" href="<{:url('real_del',['id'=>$v['goods_id']])}>" onclick="return del(1,1,1)"><span class="icon-trash-o"></span> 删除</a> </div></td>
        </tr>
        {/volist}

        <tr>
            <td style="text-align:left; padding:19px 0;padding-left:20px;"><input type="checkbox" id="checkall"/>
                全选
            </td>
            <td colspan="7" style="text-align:left;padding-left:20px;">
                <a href="javascript:DelSelect()" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="DelSelect()"> 删除</a>
            </td>
        </tr>

    </table>
</div>
<script type="text/javascript">
    // 单个删除
    function del(id,mid){
        if(confirm("您确定要删除吗?")){

        }else{
            return false;
        }
    }

    //搜索
    function changesearch(){

    }



    //全选
    $("#checkall").click(function(){
        $("input[name='id[]']").each(function(){
            if (this.checked) {
                this.checked = false;
            }
            else {
                this.checked = true;
            }
        });
    })

    //批量删除
    $(".button").click(function(){
        var arr=[];
        $(".goods_id").each(function (index,object) {
            if($(object).prop("checked")){
                arr.push($(object).val());
            }
        })

        if(arr.length>0){
            if(confirm("确认删除吗？")){
                location.href="real_del?id="+arr.join(",");
            }
        }
    })

    //批量排序
    function sorts(){
        var Checkbox=false;
        $("input[name='id[]']").each(function(){
            if (this.checked==true) {
                Checkbox=true;
            }
        });
        if (Checkbox){

            $("#listform").submit();
        }
        else{
            alert("请选择要操作的内容!");
            return false;
        }
    }


    //批量首页显示
    function changeishome(o){
        var Checkbox=false;
        $("input[name='id[]']").each(function(){
            if (this.checked==true) {
                Checkbox=true;
            }
        });
        if (Checkbox){

            $("#listform").submit();
        }
        else{
            alert("请选择要操作的内容!");

            return false;
        }
    }

    //批量推荐
    function changeisvouch(o){
        var Checkbox=false;
        $("input[name='id[]']").each(function(){
            if (this.checked==true) {
                Checkbox=true;
            }
        });
        if (Checkbox){


            $("#listform").submit();
        }
        else{
            alert("请选择要操作的内容!");

            return false;
        }
    }

    //批量置顶
    function changeistop(o){
        var Checkbox=false;
        $("input[name='id[]']").each(function(){
            if (this.checked==true) {
                Checkbox=true;
            }
        });
        if (Checkbox){

            $("#listform").submit();
        }
        else{
            alert("请选择要操作的内容!");

            return false;
        }
    }


    //批量移动
    function changecate(o){
        var Checkbox=false;
        $("input[name='id[]']").each(function(){
            if (this.checked==true) {
                Checkbox=true;
            }
        });
        if (Checkbox){

            $("#listform").submit();
        }
        else{
            alert("请选择要操作的内容!");

            return false;
        }
    }

    //批量复制
    function changecopy(o){
        var Checkbox=false;
        $("input[name='id[]']").each(function(){
            if (this.checked==true) {
                Checkbox=true;
            }
        });
        if (Checkbox){
            var i = 0;
            $("input[name='id[]']").each(function(){
                if (this.checked==true) {
                    i++;
                }
            });
            if(i>1){
                alert("只能选择一条信息!");
                $(o).find("option:first").prop("selected","selected");
            }else{

                $("#listform").submit();
            }
        }
        else{
            alert("请选择要复制的内容!");
            $(o).find("option:first").prop("selected","selected");
            return false;
        }
    }

</script>
</body>
</html>